package com.example.testhooter;

import java.util.HashMap;
import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class BindCategoryData extends BaseAdapter {

	static final String CAT_ID = "cat_id";
	static final String CAT_NAME = "cat_name";

	LayoutInflater inflater;
	ImageView thumb_image;
	List<HashMap<String, String>> categoryDataCollection;
	ViewHolder holder;

	public BindCategoryData() {

	}

	public BindCategoryData(Activity act, List<HashMap<String, String>> map) {

		this.categoryDataCollection = map;

		inflater = (LayoutInflater) act
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	public int getCount() {
		// TODO Auto-generated method stub
		// return idlist.size();
		return categoryDataCollection.size();
	}

	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	public View getView(int position, View convertView, ViewGroup parent) {

		View vi = convertView;
		if (convertView == null) {

			vi = inflater.inflate(R.layout.category_row, null);
			holder = new ViewHolder();

			holder.tvCity = (TextView) vi.findViewById(R.id.tvCity);

			vi.setTag(holder);
		} else {

			holder = (ViewHolder) vi.getTag();
		}

		holder.tvCity.setText(categoryDataCollection.get(position)
				.get(CAT_NAME));
		return vi;
	}

	static class ViewHolder {
		TextView tvCity;
	}

}
